package shop.services.manage.organize.dao.impl;

import org.springframework.stereotype.Repository;
import shop.core.common.dao.BaseDao;
import shop.core.common.dao.page.PagerModel;
import shop.services.manage.organize.bean.Organize;
import shop.services.manage.organize.dao.OrganizeDao;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description
 * @Author semstouch
 * @Date 2017/4/15
 **/
@Repository("organizeManage")
public class OrganizeDaoImpl implements OrganizeDao{
    @Resource
    private BaseDao dao;

    public void setDao(BaseDao dao) {
        this.dao = dao;
    }

    public PagerModel selectPageList(Organize e) {
        return dao.selectPageList("manage.organize.selectPageList",
                "manage.organize.selectPageCount", e);
    }

    public List selectList(Organize e) {
        return dao.selectList("manage.organize.selectList", e);
    }

    public Organize selectOne(Organize e) {
        return (Organize) dao.selectOne("manage.organize.selectOne", e);
    }


    public int delete(Organize e) {
        return dao.delete("manage.organize.deleteById", e);
    }

    public int update(Organize e) {
        return dao.update("manage.organize.update", e);
    }

    public int deletes(String[] ids) {
        Organize e = new Organize();
        for (int i = 0; i < ids.length; i++) {
            e.setId(ids[i]);
            delete(e);
        }
        return 0;
    }

    public int insert(Organize e) {
        return dao.insert("manage.organize.insert", e);
    }

    public int deleteById(int id) {
        return dao.delete("manage.organize.deleteById", id);
    }

    @Override
    public Organize selectById(String id) {
        return (Organize) dao.selectOne("manage.organize.selectById", id);
    }

    @Override
    public List<Organize> selectSubList(Organize e) {
        return dao.selectList("manage.organize.selectSubList", e);
    }

    @Override
    public List<Organize> selectSupList(Organize organize) {
        return dao.selectList("manage.organize.selectSupList", organize);
    }

    @Override
    public List<Organize> list(Organize organize) {
        return  dao.selectList("manage.organize.list", organize);
    }

    @Override
    public Organize selectByPrincipalPhone(Organize organize) {
        return (Organize)dao.selectOne("manage.organize.selectByPrincipalPhone",organize);
    }

    @Override
    public PagerModel selectSubPageList(Organize organize) {
        return dao.selectPageList("manage.organize.selectSubPageList","manage.organize.selectPageCount",organize);
    }
}
